package com.cooba.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.cooba.R;
/**
 * Created by Administrator on 2015/1/11.
 * 服务详情页面
 */
public class BookTicketsActivity extends AppCompatActivity {
    private WebView web_dp;
    private  String mMrl;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_book_tickets);
        Intent intent = getIntent();
        mMrl = intent.getStringExtra("mMrl");
        web_dp = (WebView) findViewById(R.id.web_dp);
        init();
    }

    private void init() {
        WebSettings settings = web_dp.getSettings();
        settings.setJavaScriptCanOpenWindowsAutomatically(true);//支持通过JS打开新窗口
        settings.setAppCacheEnabled(true);//是否使用缓存
        settings.setTextSize(WebSettings.TextSize.NORMAL);
        settings.setDefaultTextEncodingName("UTF-8");
        web_dp.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }
        });

        web_dp.loadUrl("http://m.ctrip.com");
        //web_dp.loadUrl(mMrl);
       // web_dp.loadDataWithBaseURL(mMrl, null, "text/html", "utf-8", null);
        web_dp.setWebViewClient(new android.webkit.WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
            }
        });
    }
    @Override
    // 设置回退
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && web_dp.canGoBack()) {
            web_dp.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

}
